/*
 * Copyright the original author or authors.
 * 
 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *	  http://www.mozilla.org/MPL/MPL-1.1.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.milib.display.ui.scroller {
	import com.googlecode.milib.base.IMLBroadcasterListener;
	import com.googlecode.milib.display.service.MLButton;

	import flash.display.MovieClip;
	import flash.utils.getQualifiedClassName;

	/**
	 * @author Marek Brun
	 */
	public class MCScrollerWithScale9Slider extends MCScrollerWithConstantLengthSlider implements IMLBroadcasterListener {
		
		private var mc_btnSlider_humps:MovieClip;
		private var mc_btnSlider_btn:MovieClip;

		public function MCScrollerWithScale9Slider(mc:MovieClip) {
			super(mc);
			
			mc_btnSlider_btn=mlmc.getMC('btnSlider.btn');			mc_btnSlider_humps=mlmc.getMC('btnSlider.humps');
			mc_btnSlider_humps.mouseEnabled=false;
			
			if(getQualifiedClassName(this).split('::')[1]=='MCScrollerWithScale9Slider'){
				setPosition(0, 1);
			}
		}
		
		override protected function getBtnSlider():MLButton {
			return mlmc.getMLButton('btnSlider.btn');
		}
		
		override protected function draw():void {
			mc.visible=visibleToTotal<1;
			var sliderLength:Number=Math.max(visibleToTotal*lengtH, 20);
			mc_btnSlider_btn.height=sliderLength;			mc_btnSlider_humps.y=sliderLength/2;
			mc_btnSlider.y=(lengtH-sliderLength)*position;
		}
		
		override protected function getSliderLength():Number {
			return mc_btnSlider_btn.height;
		}
		
	}
}
